﻿
/*
 * 打印交接文具
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Collections;

using Web.SystemConfig.ArchiveCode;
using ePlanet.ArchiveMange.Models;
using ePlanet.ArchiveMange.Services;
using DreamBuilder.Core.Container;
using Microsoft.Practices.Unity;
using ePlanet.ArchiveMange.Enum;
using ePlanet.SingleWell.Services;
using CommonModule;
using ePlanet.SingleWell.Models;
using System.IO;
using System.Text;


namespace Web.Views.ArchiveFlowView
{
    public partial class PrintHandoverCatagory : PageBase
    {
        [Dependency]
        public IArchiveMenuService ArchiveMenuService
        {
            get;
            set;
        }

        [Dependency]
        public IPageFileService PageFileService
        {
            get;
            set;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
#region 旧版本
//            try
//            {
//                int baseTypeId = ArchiveMenuService.GetArchiveBaseIDById(int.Parse(Request.QueryString["archiveType"]));
//                DataTable archiveTable = null;
//                ArrayList idList = null;
				
//                if (Request.QueryString["from"].Equals("dazl"))     //信息中心-E6
//                {
//                    idList = Session["dazl_selectedkeys_jj"] as ArrayList;

//                    this.imgGD.ImageUrl = "../../Images/uncheck.jpg";
//                    this.imgCQBG.ImageUrl = "../../Images/uncheck.jpg";
//                    this.imgSJ.ImageUrl = "../../Images/check.jpg";
//                }
//                else if (Request.QueryString["from"].Equals("dasj")) //档案上交 基层-信息中心
//                {
//                    idList = Session["dasj_selectedkeys_jj"] as ArrayList;

//                    this.imgGD.ImageUrl = "../../Images/uncheck.jpg";
//                    this.imgCQBG.ImageUrl = "../../Images/uncheck.jpg";
//                    this.imgSJ.ImageUrl = "../../Images/check.jpg";
//                }
//                else if (Request.QueryString["from"].Equals("dajs")) //档案接收 基层部门领导-信息中心
//                {
//                    idList = Session["dajs_selectedkeys_jj"] as ArrayList;

//                    this.imgGD.ImageUrl = "../../Images/uncheck.jpg";
//                    this.imgCQBG.ImageUrl = "../../Images/uncheck.jpg";
//                    this.imgSJ.ImageUrl = "../../Images/check.jpg";
//                }
//                else if (Request.QueryString["from"].Equals("dayj")) //档案移交 机关-信息中心
//                {
//                    idList = Session["dayj_selectedkeys_jj"] as ArrayList;

//                    this.imgGD.ImageUrl = "../../Images/check.jpg";
//                    this.imgCQBG.ImageUrl = "../../Images/uncheck.jpg";
//                    this.imgSJ.ImageUrl = "../../Images/uncheck.jpg";
//                }

//                lblCatagoryPageCount.Text = Session["filepagecount"] == null ? "" : Session["filepagecount"].ToString();
//                this.spanHandoverDesc.InnerText = Session["filedesc"] == null ? "" : Session["filedesc"].ToString();

//                List<string> myIdList = new List<string>();
//                foreach (var id in idList)
//                {
//                    myIdList.Add(id.ToString());
//                }

//                int attachCount = 0;
//                int pageFileAttachCount = 0;
//                IAttachmentService oIAttachmentService = UContainer.Resolve<IAttachmentService>();
//                IList<AttachmentModel> attachList;
//                DataTable dateSpanTable = null;
//                switch (baseTypeId)
//                {
//                    //文书类
//                    case ((int)ArchiveBaseType.Document):
//                        IDocumentArchiveService documentArchiveService = UContainer.Resolve<IDocumentArchiveService>();
//                        archiveTable = documentArchiveService.GetHandoverDataByIds(myIdList);
//                        lblArchiveTypeName.Text = "文书类";
//                        dateSpanTable = documentArchiveService.GetArchiveDateSpanByIds(myIdList);

//                        //电子文件数量
//                        oIAttachmentService.Initialize(AttachDbHelperString.DocumentFile);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            lblElectronicFileCount.Text = attachList.Count.ToString();
//                        }
//                        else
//                            lblElectronicFileCount.Text = "0";

//                        //特殊载体档案
//                        lblPicCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString();
//                        lblTapeCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString();
//                        lblCDCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString();
//                        lblFilmCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString();
//                        lblDiskCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString();
//                        lblBasemapCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString();
//                        lblYanxinCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString();
//                        lblYanxieCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString();
//                        lblNoInstanceCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString();
//                        lblOtherCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString();

//                        break;
//                    //会计类
//                    case ((int)ArchiveBaseType.Account):
//                        lblArchiveTypeName.Text = "会计类";
//                        IAccountArchiveService accountArchiveService = UContainer.Resolve<IAccountArchiveService>();
//                        archiveTable = accountArchiveService.GetHandoverDataByIds(myIdList);
//                        dateSpanTable = accountArchiveService.GetArchiveDateSpanByIds(myIdList);
//                        DataTable accountPageFileTable = PageFileService.GetPageFileCarrierTypeByFileIdList(myIdList);

//                        //电子文件数量
//                        oIAttachmentService.Initialize(AttachDbHelperString.AccountFile);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            attachCount = attachList.Count;
//                        }

//                        oIAttachmentService.Initialize(AttachDbHelperString.PageFile);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            pageFileAttachCount = attachList.Count;
//                        }
//                        lblElectronicFileCount.Text = (attachCount + pageFileAttachCount).ToString();


//                        //特殊载体档案
//                        lblPicCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString())).ToString();
//                        lblTapeCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString())).ToString();
//                        lblCDCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString())).ToString();
//                        lblFilmCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString())).ToString();
//                        lblDiskCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString())).ToString();
//                        lblBasemapCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString())).ToString();
//                        lblYanxinCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString())).ToString();
//                        lblYanxieCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString())).ToString();
//                        lblNoInstanceCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString())).ToString();
//                        lblOtherCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString())).ToString();

//                        break;
//                    //基建类
//                    case ((int)ArchiveBaseType.BulidProject):
//                        lblArchiveTypeName.Text = "建设项目类";
//                        IBuildProjectArchiveService buildProjectArchiveService = UContainer.Resolve<IBuildProjectArchiveService>();
//                        archiveTable = buildProjectArchiveService.GetHandoverDataByIds(myIdList);
//                        dateSpanTable = buildProjectArchiveService.GetArchiveDateSpanByIds(myIdList);
//                        DataTable buildProjectPageFileTable = PageFileService.GetPageFileCarrierTypeByFileIdList(myIdList);

//                        //电子文件数量
//                        oIAttachmentService.Initialize(AttachDbHelperString.BuildProjectFile);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            attachCount = attachList.Count;
//                        }

//                        oIAttachmentService.Initialize(AttachDbHelperString.PageFile);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            pageFileAttachCount = attachList.Count;
//                        }
//                        lblElectronicFileCount.Text = (attachCount + pageFileAttachCount).ToString();

//                        //特殊载体档案
//                        lblPicCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString())).ToString();
//                        lblTapeCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString())).ToString();
//                        lblCDCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString())).ToString();
//                        lblFilmCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString())).ToString();
//                        lblDiskCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString())).ToString();
//                        lblBasemapCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString())).ToString();
//                        lblYanxinCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString())).ToString();
//                        lblYanxieCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString())).ToString();
//                        lblNoInstanceCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString())).ToString();
//                        lblOtherCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString())).ToString();

//                        break;
//                    //设备类
//                    case ((int)ArchiveBaseType.Equipment):
//                        lblArchiveTypeName.Text = "设备类";
//                        IEquipmentService equipService = UContainer.Resolve<IEquipmentService>();
//                        archiveTable = equipService.GetHandoverDataByIds(myIdList);
//                        dateSpanTable = equipService.GetArchiveDateSpanByIds(myIdList);
//                        DataTable equipmentPageFileTable = PageFileService.GetPageFileCarrierTypeByFileIdList(myIdList);

//                        //电子文件数量
//                        oIAttachmentService.Initialize(AttachDbHelperString.Equipment);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            attachCount = attachList.Count;
//                        }

//                        oIAttachmentService.Initialize(AttachDbHelperString.PageFile);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            pageFileAttachCount = attachList.Count;
//                        }
//                        lblElectronicFileCount.Text = (attachCount + pageFileAttachCount).ToString();

//                        //特殊载体档案
//                        lblPicCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString())).ToString();
//                        lblTapeCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString())).ToString();
//                        lblCDCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString())).ToString();
//                        lblFilmCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString())).ToString();
//                        lblDiskCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString())).ToString();
//                        lblBasemapCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString())).ToString();
//                        lblYanxinCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString())).ToString();
//                        lblYanxieCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString())).ToString();
//                        lblNoInstanceCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString())).ToString();
//                        lblOtherCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString())).ToString();

//                        break;
//                    //油气勘探类
//                    case ((int)ArchiveBaseType.OliSearch):
//                        lblArchiveTypeName.Text = "油气勘探类";
//                        IOilSearchArchiveService oliSearchService = UContainer.Resolve<IOilSearchArchiveService>();
//                        archiveTable = oliSearchService.GetHandoverDataByIds(myIdList);
//                        dateSpanTable = oliSearchService.GetArchiveDateSpanByIds(myIdList);
//                        //电子文件数量
//                        oIAttachmentService.Initialize(AttachDbHelperString.Oilsearch);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            lblElectronicFileCount.Text = attachList.Count.ToString();
//                        }
//                        else
//                            lblElectronicFileCount.Text = "0";

//                        //特殊载体档案
//                        lblPicCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString();
//                        lblTapeCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString();
//                        lblCDCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString();
//                        lblFilmCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString();
//                        lblDiskCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString();
//                        lblBasemapCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString();
//                        lblYanxinCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString();
//                        lblYanxieCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString();
//                        lblNoInstanceCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString();
//                        lblOtherCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString();
//                        break;
//                    //音像类
//                    case ((int)ArchiveBaseType.AudioVedio):
//                        lblArchiveTypeName.Text = "音像类";
//                        IAudioArchiveService audioService = UContainer.Resolve<IAudioArchiveService>();
//                        archiveTable = audioService.GetHandoverDataByIds(myIdList);
//                        dateSpanTable = audioService.GetArchiveDateSpanByIds(myIdList);
//                        //电子文件数量
//                        oIAttachmentService.Initialize(AttachDbHelperString.Audiofile);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            lblElectronicFileCount.Text = attachList.Count.ToString();
//                        }
//                        else
//                            lblElectronicFileCount.Text = "0";

//                        //特殊载体档案
//                        lblPicCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString();
//                        lblTapeCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString();
//                        lblCDCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString();
//                        lblFilmCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString();
//                        lblDiskCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString();
//                        lblBasemapCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString();
//                        lblYanxinCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString();
//                        lblYanxieCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString();
//                        lblNoInstanceCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString();
//                        lblOtherCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString();

//                        break;
//                    //实物类
//                    case ((int)ArchiveBaseType.RealKind):
//                        lblArchiveTypeName.Text = "实物类";
//                        IRealKindArchiveService realService = UContainer.Resolve<IRealKindArchiveService>();
//                        archiveTable = realService.GetHandoverDataByIds(myIdList);
//                        dateSpanTable = realService.GetArchiveDateSpanByIds(myIdList);

//                        //电子文件数量
//                        oIAttachmentService.Initialize(AttachDbHelperString.RealKind);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            lblElectronicFileCount.Text = attachList.Count.ToString();
//                        }
//                        else
//                            lblElectronicFileCount.Text = "0";

//                        //特殊载体档案
//                        lblPicCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString();
//                        lblTapeCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString();
//                        lblCDCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString();
//                        lblFilmCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString();
//                        lblDiskCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString();
//                        lblBasemapCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString();
//                        lblYanxinCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString();
//                        lblYanxieCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString();
//                        lblNoInstanceCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString();
//                        lblOtherCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString();
//                        break;
//                    //科研类
//                    case ((int)ArchiveBaseType.Technology):
//                        lblArchiveTypeName.Text = "科研类";
//                        ITechArchiveService techService = UContainer.Resolve<ITechArchiveService>();
//                        archiveTable = techService.GetHandoverDataByIds(myIdList);
//                        dateSpanTable = techService.GetArchiveDateSpanByIds(myIdList);

//                        DataTable techPageFileTable = PageFileService.GetPageFileCarrierTypeByFileIdList(myIdList);

//                        //电子文件数量
//                        oIAttachmentService.Initialize(AttachDbHelperString.Technology);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            attachCount = attachList.Count;
//                        }

//                        oIAttachmentService.Initialize(AttachDbHelperString.PageFile);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            pageFileAttachCount = attachList.Count;
//                        }
//                        lblElectronicFileCount.Text = (attachCount + pageFileAttachCount).ToString();

//                        //特殊载体档案
//                        lblPicCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString())).ToString();
//                        lblTapeCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString())).ToString();
//                        lblCDCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString())).ToString();
//                        lblFilmCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString())).ToString();
//                        lblDiskCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString())).ToString();
//                        lblBasemapCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString())).ToString();
//                        lblYanxinCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString())).ToString();
//                        lblYanxieCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString())).ToString();
//                        lblNoInstanceCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString())).ToString();
//                        lblOtherCount.Text = (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString())).ToString();

//                        break;
//                    //光盘类
//                    case ((int)ArchiveBaseType.CDKind):
//                        ICDArchiveService cdService = UContainer.Resolve<ICDArchiveService>();
//                        archiveTable = cdService.GetHandoverDataByIds(myIdList);
//                        dateSpanTable = cdService.GetArchiveDateSpanByIds(myIdList);
//                        lblArchiveTypeName.Text = "光盘类";

//                        //电子文件数量
//                        oIAttachmentService.Initialize(AttachDbHelperString.CDKind);
//                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
//                        if (attachList != null)
//                        {
//                            lblElectronicFileCount.Text = attachList.Count.ToString();
//                        }
//                        else
//                            lblElectronicFileCount.Text = "0";

//                        //特殊载体档案
//                        lblPicCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString();
//                        lblTapeCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString();
//                        lblCDCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString();
//                        lblFilmCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString();
//                        lblDiskCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString();
//                        lblBasemapCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString();
//                        lblYanxinCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString();
//                        lblYanxieCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString();
//                        lblNoInstanceCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString();
//                        lblOtherCount.Text = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString();

//                        break;
//                }

//                //纸质档案
//                string yj = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='纸质' and f_keeptime='永久'").ToString();
//                string cq = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='纸质' and f_keeptime  in ('30年','25年','15年','10年')").ToString();
//                string dq = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='纸质' and f_keeptime  in ('5年','3年')").ToString();
//                string zb = archiveTable.Compute("sum(mainbodynum)", "F_CARRIERTYPE='纸质'").ToString();
//                string fb = archiveTable.Compute("sum(doplicatebodynum)", "F_CARRIERTYPE='纸质'").ToString();
//                zb = string.IsNullOrEmpty(zb) ? "0" : zb;
//                fb = string.IsNullOrEmpty(fb) ? "0" : fb;
//                lblyjArchiveCount.Text = yj;
//                lblcqArchiveCount.Text = cq;
//                lbldqArchiveCount.Text = dq;
//                lblhjArchiveCount.Text = (int.Parse(yj) + int.Parse(cq) + int.Parse(dq)).ToString();
//                lblTotalCount_zb.Text = zb;
//                lblTotalCount_fb.Text = fb;
//                lblTotalCount.Text = (int.Parse(zb) + int.Parse(fb)).ToString();

//                //所属年份
//                if (dateSpanTable != null && dateSpanTable.Rows.Count > 0)
//                {
//                    DateTime? startDate = null;
//                    DateTime? endDate = null;
//                    if (dateSpanTable.Rows[0]["starttime"] != DBNull.Value)
//                    {
//                        startDate = DateTime.Parse(dateSpanTable.Rows[0]["starttime"].ToString());
//                    }
//                    if (dateSpanTable.Rows[0]["endtime"] != DBNull.Value)
//                    {
//                        endDate = DateTime.Parse(dateSpanTable.Rows[0]["endtime"].ToString());
//                    }
//                    if (startDate.HasValue && endDate.HasValue)
//                    {
//                        lblYear.Text = string.Format("{0}至{1}"
//                        , startDate.Value.ToString("yyyy年M月")
//                        , endDate.Value.ToString("yyyy年M月"));
//                    }

//                }
//                WriteUserLog(string.Format("用户{0}查看了{1}类型档案的交接文具", CurrentUser.Real_Name, baseTypeId), OracleLogType.ArchiveManage);
//            }
//            catch (Exception ex)
//            {
//                WriteErrorLog(string.Format("用户{0}获取交接文具数据异常：{1}", CurrentUser.Real_Name, ex.Message), OracleLogType.ArchiveManage);
//            }
#endregion

#region 新版本打印
            try
            {
                int baseTypeId = ArchiveMenuService.GetArchiveBaseIDById(int.Parse(Request.QueryString["archiveType"]));
                DataTable archiveTable = null;
                ArrayList idList = null;

                StringBuilder sb = new StringBuilder();
                
                sb.Append(File.ReadAllText(
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Views\ArchiveFlowView\PrintHandoverCatagoryTemplate.htm")));

                if (Request.QueryString["from"].Equals("dazl"))     //信息中心-E6
                {
                    idList = Session["dazl_selectedkeys_jj"] as ArrayList;

                    sb.Replace("{imgGD}", "../../Images/uncheck.jpg");
                    sb.Replace("{imgCQBG}", "../../Images/uncheck.jpg");
                    sb.Replace("{imgSJ}", "../../Images/check.jpg");
                }
                else if (Request.QueryString["from"].Equals("dasj")) //档案上交 基层-信息中心
                {
                    idList = Session["dasj_selectedkeys_jj"] as ArrayList;

                    sb.Replace("{imgGD}", "../../Images/uncheck.jpg");
                    sb.Replace("{imgCQBG}", "../../Images/uncheck.jpg");
                    sb.Replace("{imgSJ}", "../../Images/check.jpg");
                }
                else if (Request.QueryString["from"].Equals("dajs")) //档案接收 基层部门领导-信息中心
                {
                    idList = Session["dajs_selectedkeys_jj"] as ArrayList;

                    sb.Replace("{imgGD}", "../../Images/uncheck.jpg");
                    sb.Replace("{imgCQBG}", "../../Images/uncheck.jpg");
                    sb.Replace("{imgSJ}", "../../Images/check.jpg");
                }
                else if (Request.QueryString["from"].Equals("dayj")) //档案移交 机关-信息中心
                {
                    idList = Session["dayj_selectedkeys_jj"] as ArrayList;

                    sb.Replace("{imgGD}", "../../Images/check.jpg");
                    sb.Replace("{imgCQBG}", "../../Images/uncheck.jpg");
                    sb.Replace("{imgSJ}", "../../Images/uncheck.jpg");
                }

                sb.Replace("{lblCatagoryPageCount}", Session["filepagecount"] == null ? "" : Session["filepagecount"].ToString());
                sb.Replace("{spanHandoverDesc}",Session["filedesc"] == null ? "" : Session["filedesc"].ToString());

                List<string> myIdList = new List<string>();
                foreach (var id in idList)
                {
                    myIdList.Add(id.ToString());
                }

                int attachCount = 0;
                int pageFileAttachCount = 0;
                IAttachmentService oIAttachmentService = UContainer.Resolve<IAttachmentService>();
                IList<AttachmentModel> attachList;
                DataTable dateSpanTable = null;
                switch (baseTypeId)
                {
                    //文书类
                    case ((int)ArchiveBaseType.Document):
                        IDocumentArchiveService documentArchiveService = UContainer.Resolve<IDocumentArchiveService>();
                        archiveTable = documentArchiveService.GetHandoverDataByIds(myIdList);
                        sb.Replace("{lblArchiveTypeName}", "文书类");
                        dateSpanTable = documentArchiveService.GetArchiveDateSpanByIds(myIdList);

                        //电子文件数量
                        oIAttachmentService.Initialize(AttachDbHelperString.DocumentFile);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            sb.Replace("{lblElectronicFileCount}", attachList.Count.ToString());
                        }
                        else
                            sb.Replace("{lblElectronicFileCount}", "0");

                        //特殊载体档案
                        sb.Replace("{lblPicCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString());
                        sb.Replace("{lblTapeCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString());
                        sb.Replace("{lblCDCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString());
                        sb.Replace("{lblFilmCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString());
                        sb.Replace("{lblDiskCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString());
                        sb.Replace("{lblBasemapCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString());
                        sb.Replace("{lblYanxinCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString());
                        sb.Replace("{lblYanxieCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString());
                        sb.Replace("{lblNoInstanceCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString());
                        sb.Replace("{lblOtherCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString());

                        break;
                    //会计类
                    case ((int)ArchiveBaseType.Account):
                        sb.Replace("{lblArchiveTypeName}", "会计类");
                        IAccountArchiveService accountArchiveService = UContainer.Resolve<IAccountArchiveService>();
                        archiveTable = accountArchiveService.GetHandoverDataByIds(myIdList);
                        dateSpanTable = accountArchiveService.GetArchiveDateSpanByIds(myIdList);
                        DataTable accountPageFileTable = PageFileService.GetPageFileCarrierTypeByFileIdList(myIdList);

                        //电子文件数量
                        oIAttachmentService.Initialize(AttachDbHelperString.AccountFile);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            attachCount = attachList.Count;
                        }

                        oIAttachmentService.Initialize(AttachDbHelperString.PageFile);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            pageFileAttachCount = attachList.Count;
                        }
                        sb.Replace("{lblElectronicFileCount}", (attachCount + pageFileAttachCount).ToString());


                        //特殊载体档案
                        sb.Replace("{lblPicCount}",         (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString())).ToString());
                        sb.Replace("{lblTapeCount}",        (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString())).ToString());
                        sb.Replace("{lblCDCount}",          (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString())).ToString());
                        sb.Replace("{lblFilmCount}",        (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString())).ToString());
                        sb.Replace("{lblDiskCount}",        (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString())).ToString());
                        sb.Replace("{lblBasemapCount}",         (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString())).ToString());
                        sb.Replace("{lblYanxinCount}",      (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString())).ToString());
                        sb.Replace("{lblYanxieCount}",      (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString())).ToString());
                        sb.Replace("{lblNoInstanceCount}",  (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString())).ToString());
                        sb.Replace("{lblOtherCount}",       (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString()) + int.Parse(accountPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString())).ToString());

                        break;
                    //基建类
                    case ((int)ArchiveBaseType.BulidProject):
                        sb.Replace("{lblArchiveTypeName}", "建设项目类");
                        IBuildProjectArchiveService buildProjectArchiveService = UContainer.Resolve<IBuildProjectArchiveService>();
                        archiveTable = buildProjectArchiveService.GetHandoverDataByIds(myIdList);
                        dateSpanTable = buildProjectArchiveService.GetArchiveDateSpanByIds(myIdList);
                        DataTable buildProjectPageFileTable = PageFileService.GetPageFileCarrierTypeByFileIdList(myIdList);

                        //电子文件数量
                        oIAttachmentService.Initialize(AttachDbHelperString.BuildProjectFile);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            attachCount = attachList.Count;
                        }

                        oIAttachmentService.Initialize(AttachDbHelperString.PageFile);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            pageFileAttachCount = attachList.Count;
                        }
                        sb.Replace("{lblElectronicFileCount}", (attachCount + pageFileAttachCount).ToString());

                        //特殊载体档案
                        sb.Replace("{lblPicCount}",        (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString())).ToString());
                        sb.Replace("{lblTapeCount}",       (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString())).ToString());
                        sb.Replace("{lblCDCount}",        (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString())).ToString());
                        sb.Replace("{lblFilmCount}",       (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString())).ToString());
                        sb.Replace("{lblDiskCount}",       (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString())).ToString());
                        sb.Replace("{lblBasemapCount}",    (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString())).ToString());
                        sb.Replace("{lblYanxinCount}",     (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString())).ToString());
                        sb.Replace("{lblYanxieCount}",    (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString())).ToString());
                        sb.Replace("{lblNoInstanceCount}", (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString())).ToString());
                        sb.Replace("{lblOtherCount}",     (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString()) + int.Parse(buildProjectPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString())).ToString());

                        break;
                    //设备类
                    case ((int)ArchiveBaseType.Equipment):
                        sb.Replace("{lblArchiveTypeName}", "设备类");
                        IEquipmentService equipService = UContainer.Resolve<IEquipmentService>();
                        archiveTable = equipService.GetHandoverDataByIds(myIdList);
                        dateSpanTable = equipService.GetArchiveDateSpanByIds(myIdList);
                        DataTable equipmentPageFileTable = PageFileService.GetPageFileCarrierTypeByFileIdList(myIdList);

                        //电子文件数量
                        oIAttachmentService.Initialize(AttachDbHelperString.Equipment);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            attachCount = attachList.Count;
                        }

                        oIAttachmentService.Initialize(AttachDbHelperString.PageFile);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            pageFileAttachCount = attachList.Count;
                        }
                        sb.Replace("{lblElectronicFileCount}", (attachCount + pageFileAttachCount).ToString());

                        //特殊载体档案
                        sb.Replace("{lblPicCount}",        (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString())).ToString());
                        sb.Replace("{lblTapeCount}",       (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString())).ToString());
                        sb.Replace("{lblCDCount}",        (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString())).ToString());
                        sb.Replace("{lblFilmCount}",       (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString())).ToString());
                        sb.Replace("{lblDiskCount}",       (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString())).ToString());
                        sb.Replace("{lblBasemapCount}",   (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString())).ToString());
                        sb.Replace("{lblYanxinCount}",     (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString())).ToString());
                        sb.Replace("{lblYanxieCount}",     (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString())).ToString());
                        sb.Replace("{lblNoInstanceCount}",(int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString())).ToString());
                        sb.Replace("{lblOtherCount}",     (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString()) + int.Parse(equipmentPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString())).ToString());

                        break;
                    //油气勘探类
                    case ((int)ArchiveBaseType.OliSearch):
                        sb.Replace("{lblArchiveTypeName}", "油气勘探类");
                        IOilSearchArchiveService oliSearchService = UContainer.Resolve<IOilSearchArchiveService>();
                        archiveTable = oliSearchService.GetHandoverDataByIds(myIdList);
                        dateSpanTable = oliSearchService.GetArchiveDateSpanByIds(myIdList);
                        //电子文件数量
                        oIAttachmentService.Initialize(AttachDbHelperString.Oilsearch);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            sb.Replace("{lblElectronicFileCount}", attachList.Count.ToString());
                        }
                        else
                            sb.Replace("{lblElectronicFileCount}", "0");

                        //特殊载体档案
                        sb.Replace("{lblPicCount}",        archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString());
                        sb.Replace("{lblTapeCount}",       archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString());
                        sb.Replace("{lblCDCount}",        archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString());
                        sb.Replace("{lblFilmCount}",      archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString());
                        sb.Replace("{lblDiskCount}",       archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString());
                        sb.Replace("{lblBasemapCount}",    archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString());
                        sb.Replace("{lblYanxinCount}",    archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString());
                        sb.Replace("{lblYanxieCount}",     archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString());
                        sb.Replace("{lblNoInstanceCount}",archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString());
                        sb.Replace("{lblOtherCount}",     archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString());
                        break;
                    //音像类
                    case ((int)ArchiveBaseType.AudioVedio):
                        sb.Replace("{lblArchiveTypeName}", "音像类");
                        IAudioArchiveService audioService = UContainer.Resolve<IAudioArchiveService>();
                        archiveTable = audioService.GetHandoverDataByIds(myIdList);
                        dateSpanTable = audioService.GetArchiveDateSpanByIds(myIdList);
                        //电子文件数量
                        oIAttachmentService.Initialize(AttachDbHelperString.Audiofile);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            sb.Replace("{lblElectronicFileCount}", attachList.Count.ToString());
                        }
                        else
                            sb.Replace("{lblElectronicFileCount}", "0");

                        //特殊载体档案
                        sb.Replace("{lblPicCount}",        archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString());
                        sb.Replace("{lblTapeCount}",      archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString());
                        sb.Replace("{lblCDCount}",        archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString());
                        sb.Replace("{lblFilmCount}",       archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString());
                        sb.Replace("{lblDiskCount}",      archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString());
                        sb.Replace("{lblBasemapCount}",    archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString());
                        sb.Replace("{lblYanxinCount}",     archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString());
                        sb.Replace("{lblYanxieCount}",     archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString());
                        sb.Replace("{lblNoInstanceCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString());
                        sb.Replace("{lblOtherCount}",     archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString());

                        break;
                    //实物类
                    case ((int)ArchiveBaseType.RealKind):
                        sb.Replace("{lblArchiveTypeName}", "实物类");
                        IRealKindArchiveService realService = UContainer.Resolve<IRealKindArchiveService>();
                        archiveTable = realService.GetHandoverDataByIds(myIdList);
                        dateSpanTable = realService.GetArchiveDateSpanByIds(myIdList);

                        //电子文件数量
                        oIAttachmentService.Initialize(AttachDbHelperString.RealKind);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            sb.Replace("{lblElectronicFileCount}", attachList.Count.ToString());
                        }
                        else
                            sb.Replace("{lblElectronicFileCount}", "0");

                        //特殊载体档案
                        sb.Replace("{lblPicCount}",        archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString());
                        sb.Replace("{lblTapeCount}",       archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString());
                        sb.Replace("{lblCDCount}",        archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString());
                        sb.Replace("{lblFilmCount}",       archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString());
                        sb.Replace("{lblDiskCount}",       archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString());
                        sb.Replace("{lblBasemapCount}",   archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString());
                        sb.Replace("{lblYanxinCount}",    archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString());
                        sb.Replace("{lblYanxieCount}",    archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString());
                        sb.Replace("{lblNoInstanceCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString());
                        sb.Replace("{lblOtherCount}",      archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString());
                        break;
                    //科研类
                    case ((int)ArchiveBaseType.Technology):
                        sb.Replace("{lblArchiveTypeName}", "科研类");
                        ITechArchiveService techService = UContainer.Resolve<ITechArchiveService>();
                        archiveTable = techService.GetHandoverDataByIds(myIdList);
                        dateSpanTable = techService.GetArchiveDateSpanByIds(myIdList);

                        DataTable techPageFileTable = PageFileService.GetPageFileCarrierTypeByFileIdList(myIdList);

                        //电子文件数量
                        oIAttachmentService.Initialize(AttachDbHelperString.Technology);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            attachCount = attachList.Count;
                        }

                        oIAttachmentService.Initialize(AttachDbHelperString.PageFile);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            pageFileAttachCount = attachList.Count;
                        }
                        sb.Replace("{lblElectronicFileCount}", (attachCount + pageFileAttachCount).ToString());

                        //特殊载体档案
                        sb.Replace("{lblPicCount}",        (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString())).ToString());
                        sb.Replace("{lblTapeCount}",       (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString())).ToString());
                        sb.Replace("{lblCDCount}",        (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString())).ToString());
                        sb.Replace("{lblFilmCount}",       (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString())).ToString());
                        sb.Replace("{lblDiskCount}",       (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString())).ToString());
                        sb.Replace("{lblBasemapCount}",    (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString())).ToString());
                        sb.Replace("{lblYanxinCount}",    (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString())).ToString());
                        sb.Replace("{lblYanxieCount}",     (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString())).ToString());
                        sb.Replace("{lblNoInstanceCount}", (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString())).ToString());
                        sb.Replace("{lblOtherCount}",      (int.Parse(archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString()) + int.Parse(techPageFileTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString())).ToString());

                        break;
                    //光盘类
                    case ((int)ArchiveBaseType.CDKind):
                        sb.Replace("{lblArchiveTypeName}", "光盘类");
                        ICDArchiveService cdService = UContainer.Resolve<ICDArchiveService>();
                        archiveTable = cdService.GetHandoverDataByIds(myIdList);
                        dateSpanTable = cdService.GetArchiveDateSpanByIds(myIdList);

                        //电子文件数量
                        oIAttachmentService.Initialize(AttachDbHelperString.CDKind);
                        attachList = oIAttachmentService.GetAttachmentModelByObjectID(myIdList);
                        if (attachList != null)
                        {
                            sb.Replace("{lblElectronicFileCount}", attachList.Count.ToString());
                        }
                        else
                            sb.Replace("{lblElectronicFileCount}", "0");

                        //特殊载体档案
                        sb.Replace("{lblPicCount}",        archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='照片'").ToString());
                        sb.Replace("{lblTapeCount}",       archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁带'").ToString());
                        sb.Replace("{lblCDCount}",        archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='磁盘'").ToString());
                        sb.Replace("{lblFilmCount}",       archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='胶片'").ToString());
                        sb.Replace("{lblDiskCount}",       archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='光盘'").ToString());
                        sb.Replace("{lblBasemapCount}",   archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='底图'").ToString());
                        sb.Replace("{lblYanxinCount}",     archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩心'").ToString());
                        sb.Replace("{lblYanxieCount}",    archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='岩屑'").ToString());
                        sb.Replace("{lblNoInstanceCount}", archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='无实体'").ToString());
                        sb.Replace("{lblOtherCount}",      archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='其他'").ToString());

                        break;
                }

                //纸质档案
                string yj = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='纸质' and f_keeptime='永久'").ToString();
                string cq = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='纸质' and f_keeptime  in ('30年','25年','15年','10年')").ToString();
                string dq = archiveTable.Compute("count(dataid)", "F_CARRIERTYPE='纸质' and f_keeptime  in ('5年','3年')").ToString();
                string zb = archiveTable.Compute("sum(mainbodynum)", "F_CARRIERTYPE='纸质'").ToString();
                string fb = archiveTable.Compute("sum(doplicatebodynum)", "F_CARRIERTYPE='纸质'").ToString();
                zb = string.IsNullOrEmpty(zb) ? "0" : zb;
                fb = string.IsNullOrEmpty(fb) ? "0" : fb;
                sb.Replace("{lblyjArchiveCount}", yj);
                sb.Replace("{lblcqArchiveCount}", cq);
                sb.Replace("{lbldqArchiveCount}", dq);
                sb.Replace("{lblhjArchiveCount}", (int.Parse(yj) + int.Parse(cq) + int.Parse(dq)).ToString());
                sb.Replace("{lblTotalCount_zb}", zb);
                sb.Replace("{lblTotalCount_fb}", fb);
                sb.Replace("{lblTotalCount}", (int.Parse(zb) + int.Parse(fb)).ToString());
                
                //所属年份
                if (dateSpanTable != null && dateSpanTable.Rows.Count > 0)
                {
                    DateTime? startDate = null;
                    DateTime? endDate = null;
                    if (dateSpanTable.Rows[0]["starttime"] != DBNull.Value)
                    {
                        startDate = DateTime.Parse(dateSpanTable.Rows[0]["starttime"].ToString());
                    }
                    if (dateSpanTable.Rows[0]["endtime"] != DBNull.Value)
                    {
                        endDate = DateTime.Parse(dateSpanTable.Rows[0]["endtime"].ToString());
                    }
                    if (startDate.HasValue && endDate.HasValue)
                    {
                        sb.Replace("{lblYear}", string.Format("{0}至{1}"
                        , startDate.Value.ToString("yyyy年M月")
                        , endDate.Value.ToString("yyyy年M月")));
                    }

                }

                string printText = File.ReadAllText(Path.Combine(
                AppDomain.CurrentDomain.BaseDirectory, @"Views\ArchiveFlowView\PrintHandoverCatagoryTemplateFrame.htm"));

                Session["jjwjPrint"] = printText.Replace("{content}", sb.ToString());
                    ClientScript.RegisterStartupScript(this.GetType(), "print",
                        "<script type='text/javascript' > window.open('PageForPrint.aspx?from=jjwj','newpage'); </script>");

                WriteUserLog(string.Format("用户{0}查看了{1}类型档案的交接文具", CurrentUser.Real_Name, baseTypeId), OracleLogType.ArchiveManage);
            }
            catch (Exception ex)
            {
                WriteErrorLog(string.Format("用户{0}获取交接文具数据异常：{1}", CurrentUser.Real_Name, ex.Message), OracleLogType.ArchiveManage);
            }
#endregion

        }
    }
}